import request from '@/utils/request'

// 发货单分页查询
export function pagingSend(query) {
  return request({
    url: '/order/projectSend/pagingSend',
    method: 'get',
    params: query
  })
}

// 发货单统计
export function statSend(query) {
  return request({
    url: '/order/projectSend/statSend',
    method: 'get',
    params: query
  })
}

// 统计平台发货失败数
export function countThirdDeliveryFail(enterpriseId) {
  return request({
    url: '/order/projectSend/countThirdDeliveryFail',
    method: 'get',
    params: { enterpriseId }
  })
}

// 获取发货单详情
export function getSendDetail(sendId) {
  return request({
    url: '/order/projectSend/getSendDetail',
    method: 'get',
    params: { sendId }
  })
}

// 根据子订单id获取列表
export function listSendByApartOrderId(apartOrderId) {
  return request({
    url: '/order/projectSend/listSendByApartOrderId',
    method: 'get',
    params: { apartOrderId }
  })
}

// 获取子订单商品并计算可发货商品
export function listCanDeliveryGoodsByApartOrderId(apartOrderId) {
  return request({
    url: '/order/projectSend/listCanDeliveryGoodsByApartOrderId',
    method: 'get',
    params: { apartOrderId }
  })
}

// 创建发货单
export function createSend(data) {
  return request({
    url: '/order/projectSend/createSend',
    method: 'post',
    data: data
  })
}

// 发货单发货
export function doSendDelivery(data) {
  return request({
    url: '/order/projectSend/doSendDelivery',
    method: 'post',
    data: data
  })
}

// 发货单删除
export function doSendDelete(sendId) {
  return request({
    url: '/order/projectSend/doSendDelete',
    method: 'post',
    data: { sendId }
  })
}

// 平台发货重试
export function doRetryThirdDelivery(sendId) {
  return request({
    url: '/order/projectSend/doRetryThirdDelivery',
    method: 'post',
    data: { sendId }
  })
}

// 发货单推送第三方
export function doSendPushThird(sendId) {
  return request({
    url: '/order/projectSend/doSendPushThird',
    method: 'post',
    data: { sendId }
  })
}

// 发货单撤销第三方
export function doSendCancelThird(sendId) {
  return request({
    url: '/order/projectSend/doSendCancelThird',
    method: 'post',
    data: { sendId }
  })
}

// 打印发货单
export function printProjectSend(data) {
  return request({
    url: '/order/projectSend/printSend',
    method: 'post',
    data: data
  })
}

// 更新发货单打印状态
export function updateProjectSendPrintStatus(waybillCode) {
  return request({
    url: '/order/projectSend/updatePrintStatus',
    method: 'post',
    params: { waybillCode }
  })
}
